import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '分类图',
    align: 'center',
    dataIndex: 'img',
    customRender: render.renderImage,
  },
  {
    title: '排序',
    align: 'center',
    dataIndex: 'sort',
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      console.log('text :>> ', text);
      return text ? '启用' : '禁用';
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '所属大类',
    field: 'header',
    component: 'Select',
    defaultValue: '1',
    componentProps: {
      options: [
        { label: '优品直供', value: '1' },
        { label: '健康管理', value: '2' },
        { label: '居家养老', value: '3' },
        { label: '我的会员', value: '4' },
      ],
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '分类图',
    field: 'img',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
    },
  },
  {
    label: '所属大类',
    field: 'header',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '优品直供', value: 1 },
        { label: '健康管理', value: 2 },
        { label: '居家养老', value: 3 },
        { label: '我的会员', value: 4 },
      ],
    },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'InputNumber',
  },
  {
    label: '状态',
    field: 'status',
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '禁用', value: 0 },
        { label: '启用', value: 1 },
      ],
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '名称', order: 0, view: 'text', type: 'string' },
  img: { title: '分类图', order: 1, view: 'image', type: 'string' },
  header: { title: '所属大类（优品直供1，健康管理2，居家养老3，我的会员4）', order: 2, view: 'number', type: 'number' },
  sort: { title: '排序', order: 3, view: 'number', type: 'number' },
  status: { title: '状态', order: 4, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
